package com.ssgz.sso.config;

import org.springframework.boot.autoconfigure.session.SessionAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.web.servlet.server.Session;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.hazelcast.config.annotation.web.http.EnableHazelcastHttpSession;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;
import org.springframework.util.ClassUtils;

@Configuration
@EnableHazelcastHttpSession
public class SessionConfig {

//    @Bean
//    public DefaultCookieSerializer cookieSerializer(ServerProperties serverProperties) {
//        Session.Cookie cookie = serverProperties.getServlet().getSession().getCookie();
//        DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
//        PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
//        map.from(cookie::getName).to(cookieSerializer::setCookieName);
//        map.from(cookie::getDomain).to(cookieSerializer::setDomainName);
//        map.from(cookie::getPath).to(cookieSerializer::setCookiePath);
//        map.from(cookie::getHttpOnly).to(cookieSerializer::setUseHttpOnlyCookie);
//        map.from(cookie::getSecure).to(cookieSerializer::setUseSecureCookie);
//        map.from(cookie::getMaxAge).to((maxAge) -> cookieSerializer.setCookieMaxAge((int) maxAge.getSeconds()));
//        return cookieSerializer;
//    }
}
